'use strict';

import { Application } from 'egg'

const apiAuthHeader = '/auth/project'
const apiSuperAuthHeader = '/super-auth/project'

const getAuthApi = (path: string) => {
  return `${apiAuthHeader}/${path}`
}

const getSuperAuthApi = (path: string) => {
  return `${apiSuperAuthHeader}/${path}`
}

export default (app: Application) => {
  const { router, controller } = app;

  router.get(getAuthApi(':id'), controller.project.show);
  
  router.post(apiSuperAuthHeader, controller.project.create);
  router.get(apiSuperAuthHeader, controller.project.index);
  router.get(getSuperAuthApi('all'), controller.project.all);
  router.delete(getSuperAuthApi(':id'), controller.project.remove);
  router.post(getSuperAuthApi(':id'), controller.project.update);
};